package com.micro.boot.config;

import javax.sql.DataSource;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.jdbc.core.JdbcTemplate;

//@Configuration
//@PropertySource("classpath:db.properties")
public class DbConfig {

	@Bean
	@ConfigurationProperties(prefix = "spring.datasource") 
	public DataSource dataSource() {
		return DataSourceBuilder.create().build();
	}
	
	
	@Bean
	@ConfigurationProperties(prefix = "spring.datasource2") 
	public DataSource dataSource2() {
		return DataSourceBuilder.create().build();
	}

	
	
	
    @Bean//(name = "primaryJdbcTemplate")
    public JdbcTemplate primaryJdbcTemplate(
            /*@Qualifier("primaryDataSource") */DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
